package com.unitech.drinks.vo;

import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 饮品分页返回对象
 * */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ResponsePageDrinks {

    private Long total;

    private Long totalPage;

    private List<ResponseDrink> data;

    //将po -> vo
    public static ResponsePageDrinks converter(PageInfo<ResponseDrink> drinkPageInfo) {
        return ResponsePageDrinks.builder()
                .total(drinkPageInfo.getTotal())
                .totalPage(new Long(drinkPageInfo.getPages()))
                .data(drinkPageInfo.getList())
                .build();

    }


}
